package com.xjrsoft.module.customer.erp_model.eRP_SalesInvoice.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customer.erp_model.eRP_SalesInvoice.entity.ErpSalesinvoice;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.module.customer.erp_model.eRP_SalesInvoice.dto.ErpSalesinvoiceListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.customer.erp_model.eRP_SalesInvoice.mapper.ErpSalesinvoiceMapper;
import com.xjrsoft.module.customer.erp_model.eRP_SalesInvoice.service.IErpSalesinvoiceService;
import com.xjrsoft.core.mp.base.BaseService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author pp
 * @since 2021-10-08
 */
@Service
@AllArgsConstructor
public class ErpSalesinvoiceServiceImpl extends BaseService<ErpSalesinvoiceMapper, ErpSalesinvoice> implements IErpSalesinvoiceService {


	@Override
	public IPage<ErpSalesinvoice> getPageList(ErpSalesinvoiceListDto pageListDto) {
		Wrapper<ErpSalesinvoice> wrapper = Wrappers.<ErpSalesinvoice>query().lambda()				.eq(!StringUtil.isEmpty(pageListDto.getF_SalesInvoiCode()), ErpSalesinvoice::getFSalesinvoicode, pageListDto.getF_SalesInvoiCode())
				.eq(!StringUtil.isEmpty(pageListDto.getF_SalesCode()), ErpSalesinvoice::getFSalescode, pageListDto.getF_SalesCode());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public String addErpSalesinvoice(ErpSalesinvoice erpSalesinvoice) {
		String erpSalesinvoiceId = IdWorker.get32UUID();
		erpSalesinvoice.setFId(erpSalesinvoiceId);
		boolean isSuccess = this.save(erpSalesinvoice);
		return isSuccess ? erpSalesinvoiceId : null;
	}

	@Override
	public boolean updateErpSalesinvoice(String id, ErpSalesinvoice erpSalesinvoice) {
		erpSalesinvoice.setFId(id);
		return this.updateById(erpSalesinvoice);
	}

}
